1. Field of The Invention
This invention relates to a computer, and more particularly, to a so-called stored program computer in which conditional statements such as an IF statement can be executed effectively.
2. Description of the Prior Art
In a programming language such as BASIC for a so-called stored program or programmed computer, conditional statements (e.g., an IF statement) are used. An IF statement can be expressed in the form of "IF X THEN Y ELSE Z". When the IF statement is executed, it is judged whether the condition X is satisfied or not. If the condition X is satisfied, the THEN clause is executed (the process Y after the key word "THEN" is executed). If the condition X is not satisfied, the ELSE clause is executed (the process Z after the key word ELSE is executed). In other words, when the IF statement is executed, either the THEN clause or the ELSE clause is not executed.
With reference to FIG. 9, the execution of an IF statement in the prior art will be described more specifically. Column (a) in FIG. 9 shows program data of an IF statement entered through a key board into a memory of a computer. The symbol "OD" at address 15 designates a delimiter which separates this statement from the succeeding statement. Column (b) in FIG. 9 illustrates the program of column (a) converted into an intermediate language. First, it is judged whether the condition "A=1" is satisfied or not. If the condition is satisfied, the program data for the THEN clause are read from the memory to execute the THEN clause (namely, the number "10" is substituted for the variable "B"). Then, the key word "ELSE" of the ELSE clause is read, and the computer judges that this clause is not to be executed. The program data "C", "=", "2" and "0" stored in the addresses following the address of the key word "ELSE" are sequentially read out to be skipped until the delimiter "OD" stored in address Oe is read.
If the condition is not satisfied, the key word "THEN" of the THEN clause is read, and the computer judges that this clause is not to be executed. The program data "B", "=", "1" and "0" stored in the addresses following the address of the key word "THEN" are sequentially read out to be skipped until the key word "ELSE" stored in address 09 is read. Thereafter, the ELSE clause stored in addresses 09 to 0d are executed to substitute the number "20" for the variable "C".
As described above, when a conditional statement is executed in a prior art computer, program data which are not necessary to be executed are read, resulting in wasting a substantial period of time.